/*
 * state_machine_pub.h
 *
 *  Created on: Jul 16, 2012
 *      Author: Eugene Parkhomenko
 */

#if !defined(__STATE_MACHINE_H__)
#define __STATE_MACHINE_PUB_H__

#include "sm_types.h"
#include "sm_error.h"

typedef void * SM_INSTANCE_DESCRIPTOR;

typedef struct ST_SM_STATE_TAG
{
	unsigned int ulId;
	void (*pfEntry)(void *pvData);
	void (*pfExit)(void *pvData);
} ST_SM_STATE;


typedef struct ST_SM_TRANSITION_TAG
{
	unsigned int ulEventId;
	unsigned int ulFrom;
	unsigned int ulTo;
	int (*pfGuard)(void *pvData);
	void (*pfAction)(void *pvData);
} ST_SM_TRANSITION;

EN_SM_ERR_CODE SM_init(SM_INSTANCE_DESCRIPTOR *ptSthInstance, ST_SM_STATE *pstStateTable, ST_SM_TRANSITION *pstTransitionTable);
EN_SM_ERR_CODE SM_handle_event(unsigned int ulEvent);
EN_SM_ERR_CODE SM_stop(SM_INSTANCE_DESCRIPTOR tSthInstance);

unsigned int SM_get_current_state(void);
unsigned int SM_get_last_event(void);
#endif /* __STATE_MACHINE_PUB_H__ */
